{strip}
{literal}

<script>

function getAddForm(){
		
	$.ajax({
		type: "GET",
		url: "/statuses/add",
		data: {
			
		},
		success: function(data){
			showPopup(data, 'Add new status', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function getEditForm(statusesId){
		
	$.ajax({
		type: "GET",
		url: "/statuses/edit",
		data: {
			statusesId: statusesId
		},
		success: function(data){
			showPopup(data, 'Edit details', false);
		},
		error: function(xhr, statusText, errorThrown){
			showPopup(xhr.responseText, statusText, false);
		}    
	
	});
}

function deleteStatus(statusesId){
	if (confirm('Are you sure you want to remove this status?')){
		$.ajax({
			type: "GET",
			url: "/statuses/delete",
			data: {
				statusesId: statusesId
			},
			success: function(data){
				//showPopup(data, 'Delete section', false);
				window.location.reload();
			},
			error: function(xhr, statusText, errorThrown){
				showPopup(xhr.responseText, statusText, false);
			}
	
		});
		
	}
	return false;
}
</script>

{/literal}

<!-- content -->
<div id="content">
    <div id="content_left">
		
		<div>
			<h2>STATUSES</h2>
		</div>

		<div>
			<a class="button_" href="#" onclick="getAddForm();">{$commonLocale->t('ADD NEW')}</a>
		</div>
		{assign var=currCatalogue value=''}
		{foreach from=$statuses item=s name=forU}
		{if $currCatalogue != $s->getCatalogue()->getCatalogue()}
			
			<h2 style="margin-top: 25px; margin-bottom: 1px;border-bottom: 2px solid silver">{$s->getCatalogue()->getCatalogue()}</h2>
			{assign var=currCatalogue value=$s->getCatalogue()->getCatalogue()}
		{/if}
		<div class="admin_list">
			<div class="left" style="width: 250px;">
				<div>{$s->getStatus()}</div>
				<div class="sKeywords">{$s->getDescription()|nl2br}</div>
			</div>
			<div class="left">
				<a href="#" onclick="getEditForm({$s->getId()});" class="button_">EDIT</a>&nbsp;
				<a href="#" onclick="deleteStatus({$s->getId()});" class="button_">DEL</a>&nbsp;
			</div>
			<div class="clear"> </div>
		</div>
		{/foreach}
		
	</div>
	<div id="content_right">
		{if $loggedUser->getIsAdministrator()}
			{include file='admin/menu.tpl'}
		{/if}
		
	</div>
</div>
<!-- end content  -->
{/strip}